<template>
  <div>
    <h2>Hello</h2>
    <button @click="abcd">点我</button>
  </div>
</template>

<script>
import { inject } from 'vue'

export default {
  setup() {
    // 注入 key1 与 key2
    const value1 = inject('key1')
    const value2 = inject('key2')

    const value3 = inject('key3')
    const value4 = inject('key4', 'hello')
    console.log('value1', value1) // 'value1'
    console.log('value2', value2) // 'value2'
    console.log('value3', value3) // undefined
    console.log('value4', value4) // 'hello'

    const value5 = inject('key5') 
    const abcd = inject('fn1')
    console.log('value5', value5)

    return {
      abcd
    }
  }
}
</script>
